package com.ruoyi.framework.web.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.wq.domain.vo.WqUserPlayVO;
import com.ruoyi.wq.service.IWqUserPlayService;

@Component
public class PlayService {
	
	@Autowired
	private ISysUserService sysUserService;
	
	@Autowired
	private IWqUserPlayService wqUserPlayService;

	public boolean playSuccess(WqUserPlayVO wqUserPlay) {
		SysUser user = sysUserService.getById(wqUserPlay.getUserId());
		if("2".equals(user.getPlayStatus())){
			throw new ServiceException("已审批通过");
		}
		
		wqUserPlayService.saveOrUpdateBatch(wqUserPlay.getPlayList());
		
		user.setPlayStatus("2");
		user.setCashRate(wqUserPlay.getCashRate());
		sysUserService.updateById(user);
		return true;
	}

}
